home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / byte400.arc / BYTE.DOC next >
Text File  |  1989-11-15  |  23KB  |  595 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.        
  8.        
  9.        
  10.        
  11.        
  12.        
  13.        
  14.        
  15.                                Byte, Version 4.00
  16.                      Copyright (c) 1987-89 SoftCircuits (tm)
  17.                               Program documentation
  18.                                          
  19.                                  Updated 8/6/89
  20.        
  21.        
  22.        
  23.        
  24.        
  25.        
  26.                 Contents                                      Page
  27.                  
  28.                 1.0 Overview.....................................2
  29.                 2.0 Getting Started..............................2
  30.                 3.0 Manipulating the Byte Value..................3
  31.                 4.0 The Command Window...........................5
  32.                 5.0 Reading Memory...............................5
  33.                 6.0 Program Release Information..................6
  34.                  
  35.                  
  36.                                     Appendix
  37.                  
  38.                 A.1 Bytes, Bits and Binary.......................6
  39.                 A.2 What is ASCII?...............................7
  40.                 A.3 What is Hexadecimal?.........................7
  41.                 A.4 What is Octal................................7
  42.                 A.5 How is the Color Attribute Used?.............8
  43.                 A.6 Segmented Addressing.........................8
  44.                  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                   Page - 1 of 9
  64.  
  65.  
  66.  
  67.  
  68.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  69.  
  70.  
  71.  
  72.  
  73.             
  74.       1.0  Overview:
  75.            This Program allows you to look at how a computer uses a byte of
  76.            memory to store decimal, hexadecimal, octal, binary, ASCII, and
  77.            color attribute values. This program is for anyone wanting a
  78.            better understanding of how a series of tiny electronic
  79.            switches, called bits, are used to store information. It will be
  80.            of the most benefit to anyone learning to program in languages
  81.            such as C and assembly. Byte can also serve as a reference for
  82.            advanced programmers.
  83.             
  84.            This documentation describes all the features of Byte and also
  85.            provides a brief tutorial in the appendix.
  86.        
  87.       2.0  Getting Started:
  88.            To start Byte, enter BYTE at the DOS prompt with BYTE.EXE in the
  89.            current directory.
  90.             
  91.            2.1  Options:
  92.                 You can include any of the following options when you start
  93.                 Byte:
  94.                  
  95.                 /q   Quick display (CGA only). This option forces Byte to
  96.                      write to the screen as fast as possible. Use this
  97.                      option if you have a CGA display adapter that does not
  98.                      snow (flicker white spots). This option is used by
  99.                      default if your display adapter is not a CGA.
  100.                       
  101.                 /b   Black and white. This option forces Byte to suppress
  102.                      colors. Use this option if you have a color adapter
  103.                      with a non-color display (composite monitors, for
  104.                      example).
  105.                  
  106.                 /m   Suppress mouse support. This option forces Byte to
  107.                      ignore your mouse. It has no effect if you don't have
  108.                      a mouse.
  109.                       
  110.                 These options are entered on the command line when you
  111.                 start Byte. Note that multiple options must be separated
  112.                 with at least 1 space. The following example would start
  113.                 Byte in black and white mode and force it to ignore your
  114.                 mouse:
  115.                  
  116.                      byte /b /m
  117.        
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                   Page - 2 of 9
  130.  
  131.  
  132.  
  133.  
  134.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  135.  
  136.  
  137.  
  138.  
  139.            2.2  The Byte Screen:
  140.                 The Byte screen consists of eight connecting boxes that
  141.                 represent the eight bits of a byte. The boxes contain
  142.                 either a 1 to represent a bit that's turned on, or a 0 for
  143.                 a bit that's turned off. See appendix A.1 for more
  144.                 information about bytes and bits.
  145.                  
  146.                 The window in the lower portion of the screen is divided
  147.                 into 4 sections. The center section displays the value of
  148.                 the byte in decimal, hexadecimal, octal, binary, and ASCII
  149.                 notation. The top, right section displays the color
  150.                 attribute equivalent of the byte value. The section below
  151.                 that shows the current memory address. Section 5.0 shows
  152.                 how to read from, and change this address. The left section
  153.                 of the window is the command window. Section 4.0 describes
  154.                 the operations of this window.
  155.        
  156.            2.3  The Menu:
  157.                 The top line of the screen shows the menu items currently
  158.                 available. You can select one by pressing the highlighted
  159.                 key. If you have a mouse, you can selected an item by
  160.                 clicking the mouse on the desired item.
  161.             
  162.       3.0  Manipulating the Byte Value:
  163.            This section describes the simplest methods to change the value
  164.            of the byte.
  165.        
  166.            3.1  Switching Bits:
  167.                 Byte allows you to make changes to the individual bits of
  168.                 the byte.
  169.        
  170.                 3.1.1  Moving the Bit Highlight:
  171.                        The bit highlight points to the bit that is to be
  172.                        affected by switching (explained in paragraph
  173.                        3.1.2). You can use the left and right cursor arrows
  174.                        to move the highlight to any of the eight bits.
  175.                        Press the Home key to move the highlight to bit 0.
  176.                        This is the right-most bit. The End key will move
  177.                        the highlight to bit 7 (the left-most bit).
  178.        
  179.                 3.1.2  Switching Bits:
  180.                        Since the bits are either on or off, the bit boxes
  181.                        contain either a 1 to indicate on, or a 0 to
  182.                        indicate off. The cursor up key will switch the
  183.                        current bit on while the cursor down key switches it
  184.                        off. If you have a mouse, you can toggle a bit by
  185.                        clicking the left mouse button on the bit to be
  186.                        switched. See appendix A.1 for more information
  187.                        about bits.
  188.        
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                   Page - 3 of 9
  196.  
  197.  
  198.  
  199.  
  200.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  201.  
  202.  
  203.  
  204.  
  205.            3.2  Incrementing and Decrementing the Byte Value:
  206.                 A good way to get a feel for how a byte uses 8 bits to
  207.                 count is by incrementing the byte value and observing the
  208.                 action of the individual bits. To do this, press the PgUp
  209.                 key. You can hold this key down to watch Byte count
  210.                 rapidly. Likewise, the PgDn key causes Byte to count
  211.                 backwards, or decrement the byte value.
  212.        
  213.            3.3  Reset and "Not":
  214.                 Pressing the Delete key will switch all of the bits to off.
  215.                 This makes the byte equal to 0. Pressing the Insert key
  216.                 will "Not" the bits. "Not" is a logical operator. In this
  217.                 instance, it simply switches every bit of the byte. If a
  218.                 bit is 0, it becomes 1, if it's 1 it becomes 0.
  219.        
  220.            3.4  Shifting and Rotating Bits:
  221.                 Unless you've programmed in C or assembly language, you
  222.                 probably aren't familiar with shifting bits. But the idea
  223.                 is pretty straight forward.
  224.        
  225.                 3.4.1  Shifting:
  226.                        Pressing Shift-right (this means to press the right
  227.                        cursor key once while holding down the shift key)
  228.                        causes each bit to take on the value of the bit to
  229.                        its left, and the left most bit becomes zero. The
  230.                        result is that each bit seems to move to the right
  231.                        with the right-most bit dropping off at the end.
  232.                        Press Shift-left to reverse the direction.
  233.        
  234.                 3.4.2  Rotating:
  235.                        Pressing Control-right does the same thing as
  236.                        shifting right except that the right-most bit "wraps
  237.                        around" to the other side so that bit 7 takes on the
  238.                        value of bit 0. This results in the bits appearing
  239.                        to rotate around. Again, press Control-left to
  240.                        reverse the direction.
  241.        
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                   Page - 4 of 9
  262.  
  263.  
  264.  
  265.  
  266.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  267.  
  268.  
  269.  
  270.  
  271.       4.0  The Command Window:
  272.            The most flexible way to change the byte value is by entering
  273.            one of the following commands in the command window.
  274.             
  275.            MOV n  Set the byte equal to n     INC    Increment (add 1)
  276.            CLEAR  Clear bits (byte = 0)       DEC    Decrement (subtract 1)
  277.             
  278.            ADD n  Add n                       MUL n  Multiply by n
  279.            SUB n  Subtract n                  DIV n  Divide by n
  280.             
  281.            AND n  And bits with n             XOR n  Xor bits with n
  282.            OR n   Or bits with n              NOT    Reverse each bit
  283.             
  284.            SHR n  Shift right n bits          ROR    Rotate right n bits
  285.            SHL n  Shift left n bits           ROL    Rotate left n bits
  286.             
  287.            n can be any number from 0 to 255. You can specify decimal,
  288.            hexadecimal, octal, or binary notation by appending d, h, o, or
  289.            b to the number. n can also be an ASCII character enclosed in
  290.            single or double quotation marks. Appending a d is optional
  291.            because decimal is assumed by default.
  292.             
  293.            Examples:
  294.             
  295.                 mov "a"
  296.             
  297.            This makes the byte value 97 (the ASCII value for "a").
  298.             
  299.                 add 3dh
  300.             
  301.            This adds 61 (hexadecimal 3D) to the value of the byte. Note
  302.            that overflow is ignored. For example, if 1 is added to 255, the
  303.            result would be 0.
  304.        
  305.       5.0  Reading Memory:
  306.            Byte makes it easy to read a value in your computer's memory.
  307.            The current memory address is displayed in the lower, right
  308.            portion of the screen. Any time this value is changed, the byte
  309.            will be set to the value at the new memory location.
  310.        
  311.            5.1  Entering a Memory Address:
  312.                 Press the F2 key to enter a new memory address. Addresses
  313.                 are entered in the form xxxx:xxxx. Where xxxx is a
  314.                 hexadecimal number from 0 - FFFF. The first number
  315.                 specifies the segment address, and the second number
  316.                 specifies the offset address. The two values are separated
  317.                 with a colon. If only one number is entered, it will
  318.                 specify the offset address. You can press Shift-F2 to re-
  319.                 read the current address. See appendix A.6 for more
  320.                 information about segmented addressing.
  321.             
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                   Page - 5 of 9
  328.  
  329.  
  330.  
  331.  
  332.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  333.  
  334.  
  335.  
  336.  
  337.            5.2  Adjusting a Memory Address:
  338.                 You can also increment or decrement the current address.
  339.                 This allows you to browse through an area of your
  340.                 computer's memory. Press Shift-Up and Shift-Down to
  341.                 increment and decrement the offset address. This has the
  342.                 effect of reading each consecutive byte. Press Shift-PgUp
  343.                 and Shift-PgDn to increment and decrement the segment
  344.                 address. This has the effect of reading every 16 bytes.
  345.        
  346.       6.0  Program Release Information:
  347.            The Byte package, which consists of the files BYTE.EXE and
  348.            BYTE.DOC, may be used and distributed freely, on the condition
  349.            that it is distributed in full and unchanged, and that no fee is
  350.            charged for such use or distribution. This package is released
  351.            as is, and SoftCircuits makes no expressed or implied warranties
  352.            of any kind.
  353.             
  354.            SoftCircuits is always looking out for new ideas, as well as
  355.            information about program errors (be sure to include the version
  356.            number). If you have a comment or question, write us at the
  357.            address below. All letters requesting a response, will receive
  358.            one.
  359.        
  360.                 SoftCircuits Programming
  361.                 Box 811
  362.                 Tustin, CA 92681 - 0811
  363.                  
  364.        
  365.                                     Appendix
  366.        
  367.       A.1  Bytes, Bits and Binary?:
  368.            Since a computer is an electronic device, it's not able to work
  369.            with characters, digits or conventional numbers. About all a
  370.            computer "understands" is on or off. So, a system has been
  371.            devised that uses thousands of tiny, electronic, on-off switches
  372.            called bits to store information.
  373.        
  374.            For us to understand the computer's way of counting, we'll use a
  375.            1 to represent a bit that is turned on, and a 0 to represent a
  376.            bit that's turned off. The Byte screen shows 8 such bits because
  377.            there are, of course, 8 bits in one byte. If you were to ignore
  378.            the boxes, all you would have left is a row of zeros and ones.
  379.            This row of zeros and ones represents the binary numbering
  380.            system. Binary because each digit only has two possible values
  381.            (0 or 1) as opposed to our traditional numbering system
  382.            (decimal) in which each digit has 10 possible values (0 - 9). So
  383.            we can say that 00000000b is how we write 0 in binary notation.
  384.            The b is added to indicates that it's a binary number.
  385.        
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                   Page - 6 of 9
  394.  
  395.  
  396.  
  397.  
  398.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  399.  
  400.  
  401.  
  402.  
  403.            For us to be able to store as many different numbers as possible
  404.            in one byte, we need to assign each bit a different value. You
  405.            may have noticed the bit numbers shown on the Byte display, 0 -
  406.            7 from right to left. Well, the value that we'll give to each
  407.            bit will be 2 to the power of its bit number. For example, bit
  408.            3, when turned on, has a value of 2 to the power of 3. It adds 8
  409.            (2 * 2 * 2) to the total value of the byte.
  410.        
  411.            To illustrate, activate Byte and type
  412.             
  413.                 mov 1
  414.             
  415.            in the command window and press Return. The bits are now
  416.            00000001b. Notice that the decimal value, in the lower portion
  417.            of the screen is 1 (2 to the power of 0). Next, enter
  418.             
  419.                 shl 1
  420.             
  421.            or press Shift-left. This moves the bit that is switched on to
  422.            bit 1. Now the bits are 00000010b. Notice that the decimal value
  423.            is now 2 (2 to the power of 1). You can continue shifting the
  424.            bits and observe the decimal value change each time you do.
  425.        
  426.            Next, press the Delete key. The byte now equals 0. Now press the
  427.            PgUp key repeatedly. This increments the value of the byte.
  428.            Notice both the decimal and bit values as Byte counts.
  429.        
  430.       A.2  What is ASCII?:
  431.            ASCII is the acronym for American national Standard Code for
  432.            Information Interchange. The computer stores a table of ASCII
  433.            characters in memory, and when the computer is instructed to
  434.            write a character to the screen, it looks up the value in the
  435.            table and then displays the character that corresponds to that
  436.            value.
  437.        
  438.       A.3  What is Hexadecimal?:
  439.            Where decimal is base 10 and binary is base 2, hexadecimal is
  440.            base 16. Since 16 digits are needed, the hexadecimal digits are
  441.            0 - 9, followed by A - F. Hexadecimal notation is used often in
  442.            computers because a hex digit has exactly the same range as 4
  443.            bits (one nibble). Two hex digits have exactly the same range as
  444.            8 bits (one byte). You can easily become familiar with the
  445.            hexadecimal numbering system by observing the hexadecimal
  446.            display on the Byte screen while changes are made to the byte
  447.            value.
  448.        
  449.       A.4  What is Octal?:
  450.            Where decimal is base 10 and hexadecimal is base 16, octal is
  451.            base 8.
  452.        
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                   Page - 7 of 9
  460.  
  461.  
  462.  
  463.  
  464.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  465.  
  466.  
  467.  
  468.  
  469.       A.5  How is the Color Attribute Used?:
  470.            When an IBM-standard personal computer is in normal text mode,
  471.            it displays 2000 characters on the screen (25 x 80). The
  472.            computer uses two bytes of memory for each character. One byte
  473.            contains the ASCII value (character), and the other byte
  474.            contains the character's color attribute.
  475.        
  476.            The box in the lower right portion of the Byte screen shows the
  477.            color attribute for the current byte value. You will, of course,
  478.            see more variation if you're using a color monitor. This box may
  479.            be confusing at first if you're used to languages like BASIC,
  480.            but if you ever want to use color in a program written in
  481.            assembly language or C, then you will want a good understanding
  482.            of the relationship between the byte value and the colors you
  483.            see in the color attribute window.
  484.        
  485.            A common type of color monitor is the RGB monitor. So named
  486.            because the screen is made up of Red, Green and Blue dots. It
  487.            can be interesting and informative to watch the color attribute
  488.            change as different bits are switched on and off. The following
  489.            table shows the meaning of each bit in relationship to the color
  490.            attribute.
  491.        
  492.                      Bit:                  Meaning:
  493.        
  494.                      0.............Blue(foreground)
  495.                      1............Green(foreground)
  496.                      2..............Red(foreground)
  497.                      3...........Bright(foreground)
  498.                      4.............Blue(background)
  499.                      5............Green(background)
  500.                      6..............Red(background)
  501.                      7............Blink(foreground)
  502.        
  503.            As already stated, monochrome monitors will, of course, show
  504.            less variation than color monitors. But in text mode, they use
  505.            video memory in exactly the same way (2000 characters, one byte
  506.            for ASCII, one byte for the color attribute). Bits 3 and 7 have
  507.            the same effect on both types of monitors. On a monochrome
  508.            monitor, bit 0 by itself, shows underlined characters.
  509.            Underlined characters aren't available on color monitors.
  510.        
  511.       A.6  Segmented Addressing:
  512.            The central processing unit (CPU) of the IBM-standard personal
  513.            computer works with numbers in word units. A word is equal to 16
  514.            bits, and 16 bits are equal to 2 bytes. So, a word has a range
  515.            of 0 - 65,535 (hexadecimal FFFF). This range is often referred
  516.            to as 64k. However, you're probably aware that IBM-standard
  517.            personal computers are capable of accessing considerably more
  518.            than 64k. So how does the computer use word values to keep track
  519.            of more than 64k of memory? This brings us to segmented
  520.            addressing, one of the most confusing aspects about IBM-standard
  521.            personal computers.
  522.        
  523.  
  524.  
  525.                                   Page - 8 of 9
  526.  
  527.  
  528.  
  529.  
  530.              Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits
  531.  
  532.  
  533.  
  534.  
  535.            Segmented addressing is the method used to address more than 64k
  536.            using word values. This method has an effective range of 0 -
  537.            1,048,575 (hexadecimal FFFFF). This range is often referred to
  538.            as 1 meg. Segmented addressing is written in the form:
  539.             
  540.                 xxxx:xxxx
  541.             
  542.            Where xxxx is a hexadecimal number from 0 - FFFF. The first
  543.            number specifies the segment address and the second number
  544.            specifies the offset address. The two numbers are combined to
  545.            create a single address value by shifting the segment 4 bits
  546.            left and adding the two together.
  547.             
  548.                 Segment:  B377
  549.                 Offset:    48D0
  550.                           =====
  551.                 Address:  B8040
  552.             
  553.            So B377:48D0 points to address B8040 (decimal 753,728). One
  554.            peculiarity that results is that the same address can be written
  555.            different ways. The following addresses would all point to the
  556.            same location in memory.
  557.             
  558.                 B800:0040 = B8040
  559.                 B804:0000 = B8040
  560.                 B000:8040 = B8040
  561.                 B377:48D0 = B8040
  562.             
  563.            You may wonder why the numbers weren't combined as follows:
  564.             
  565.                 B377:48D0 = B37748D0
  566.             
  567.            This is the way programs store variables too large to fit in a
  568.            single word. This would give the computer a range of 0 -
  569.            4,294,967,295! However, this method would mean that each time
  570.            the computer executed an instruction, it would have to
  571.            recalculate both the segment and offset values to determine the
  572.            address of the next instruction. This would be much less
  573.            efficient than the method used.
  574.             
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                   Page - 9 of 9
  592.  
  593.  
  594.  
  595.